package base.render.gui;
import java.awt.Color;
import java.awt.Graphics2D;

import base.world.WorldOfButtons;

public abstract class GuiButton extends Gui
{
	protected int buttonID;
	
	protected String label = "";
	
	public GuiButton(int par1, int par2, int par3, String par4)
	{
		super(par2, par3, 0);
		this.buttonID = par1;
		
		this.label = par4;
	}
	
	public void onRender(Graphics2D par1Graphics)
	{
		super.onRender(par1Graphics);
		int fontSize = par1Graphics.getFont().getSize();
		par1Graphics.setColor(Color.BLUE);
		par1Graphics.fillRect(this.x-4, this.y-8, this.getLabelLength(), 32);
		par1Graphics.setColor(Color.WHITE);
		par1Graphics.drawString(label, x, y+fontSize);
	}
	
	public abstract void doUpdate(int par1);
	
	protected boolean isCurrentButton(int par1, WorldOfButtons par2World)
	{
		return par2World != null ? par2World.getCurrentButtonID() == par1 : false;
	}
	
	public String getLabel()
	{
		return this.label;
	}
	
	public int getLabelLength()
	{
		return this.label.length() * 8;
	}
	
	public WorldOfButtons getWorldButton()
	{
		return this.getWorldObj() instanceof WorldOfButtons ? (WorldOfButtons) this.getWorldObj() : null;
	}
	
	public boolean isDead()
	{
		return false;
	}
}
